package com.yuexun.beilunpatient.ui.doctor.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.doctor.bean.SignDocInfoBean;
import com.yuexun.beilunpatient.ui.doctor.model.IDoctorModel;
import com.yuexun.beilunpatient.ui.doctor.presenter.ISignDoctorPresenter;
import com.yuexun.beilunpatient.ui.doctor.ui.view.ISignDoctorView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/12/4.
 */
public class SignDoctorPresenter implements ISignDoctorPresenter {

    private ISignDoctorView view;
    private IDoctorModel model;

    public SignDoctorPresenter(ISignDoctorView view, IDoctorModel model) {
        this.view = view;
        this.model = model;
    }

    @Override
    public void inquireContractedPatientSignDocInfo(Map<String, String> praise) {
        model.inquireContractedPatientSignDocInfo(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<SignDocInfoBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取签约医生信息失败");
                    }

                    @Override
                    public void onNext(BaseEntity<SignDocInfoBean> bean) {
                        view.getSignDocInfo(bean);
                    }
                });
    }
}
